import { useEffect } from 'react';
import {
  Route,
  HashRouter as Router,
  Routes,
  useNavigate,
} from 'react-router-dom';
// import icon from '../../assets/icon.svg';
import './App.css';
// import  ThreeJsRouter from './pages/ThreeJs/router'
import SplitPdf from './pages/MyWorkTools/pdf/SplitPdf';
import ViewLocalPDF from './pages/MyWorkTools/pdf/viewLocalPdf';
import Demo3dHuluBaby from './pages/ThreeJs/3d-hulu-baby';
import Demo3dHuluBabyGlb from './pages/ThreeJs/3d-hulu-baby/index-glb';
import DemoAIBot from './pages/ThreeJs/demo-AI-Robot';
import Demo1SceneCube from './pages/ThreeJs/demo1/Demo1SceneCube';
// import FileToPdf from './pages/MyWorkTools/pdf/FileToPdf';
import Agent3D from './pages/electron/ai-agent/agent-3d';
import MlultiWindow from './pages/electron/MlultiWindow';
import Home from './pages/Home';
import Xbot from './pages/ThreeJs/3d-hulu-baby/xbot';
import Xbot2 from './pages/ThreeJs/3d-hulu-baby/xbot-2';

function NavigationHandler() {
  const navigate = useNavigate();
  useEffect(() => {
    window.electronAPI.onNativate((event: any, path: string) => {
      navigate(path);
    });

    return () => {
      // window.electronAPI.removeAllListeners('nativate');
    };
  }, [navigate]);
  return null;
}

export default function App() {
  return (
    <Router>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/threejs/demo1" element={<Demo1SceneCube />} />
        <Route path="/threejs/3d-hulu-baby" element={<Demo3dHuluBaby />} />
        <Route
          path="/threejs/3d-hulu-baby-glb"
          element={<Demo3dHuluBabyGlb />}
        />
        <Route path="/threejs/xbot" element={<Xbot />} />
        <Route path="/threejs/xbot-2" element={<Xbot2 />} />

        <Route path="/threejs/demo-AI-Robot" element={<DemoAIBot />} />
        <Route path="/myTools/pdf/splitByPageNo" element={<SplitPdf />} />
        <Route path="/myTools/pdf/viewLocalPDF" element={<ViewLocalPDF />} />
        <Route path="/electron/multiWindow" element={<MlultiWindow />} />
        <Route path="/electron/agent3D" element={<Agent3D />} />
        {/* <Route path="/myTools/pdf/FileToPdf" element={<FileToPdf />} /> */}
      </Routes>
      <NavigationHandler />
    </Router>
  );
}
